﻿using System;
using NationalInstruments.VisaNS;

namespace demo1
{
    class Program
    {
        private ResourceManager resourceManager = null;
        private TcpipSocket socket = null;
        public void Idn(string resourceName)
        {
            string str1;
            resourceManager = ResourceManager.GetLocalManager();
            socket = (TcpipSocket)resourceManager.Open(resourceName);//打开仪器
            socket.Write("*IDN?\n");//查询仪器标识
            str1 = socket.ReadString(79);//读取79个字节   
            socket.Dispose();
            Console.WriteLine(str1.ToString());//输出查询到的仪器标识
            Console.ReadLine();
        }
        static void Main(string[] args)
        {
            Program oa = new Program();//实例化              
            oa.Idn("TCPIP0::172.141.64.51::5025::SOCKET");//TCPIP0::127.0.0.1::5025::SOCKET为网络分析仪的IP地址和端口号。这里使用的是我的配置，要根据自己的情况进行改动。 
        }
    }
}